package com.baitengsoft.patentservicemonitor.api.service.impl;

import com.baitengsoft.patentservicemonitor.api.dao.SystemBaseDao;
import com.baitengsoft.patentservicemonitor.api.entity.*;
import com.baitengsoft.patentservicemonitor.api.model.ApplicantInfoModel;
import com.baitengsoft.patentservicemonitor.api.model.PacPatentInfoCountModel;
import com.baitengsoft.patentservicemonitor.api.service.SystemBaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by 周俊 on 2018/1/3.
 * http://localhost:8126/swagger-ui.html#/
 */
@Service("SystemBaseService")
public class SystemBaseImpl implements SystemBaseService {
    @Autowired
    SystemBaseDao systemBaseDao;

    @Override
    public void createNewTable(String tableName) {
        systemBaseDao.createNewTable(tableName);
    }

    @Override
    public void dropTable(String tableName) {
        systemBaseDao.dropTable(tableName);
    }

    @Override
    public List<Integer> queryWebPlatformList() {
        List<WebPlatformEntity> webPlatformEntityList = systemBaseDao.queryWebPlatformList();
        List<Integer> webPlatformIdList = new ArrayList<>();
        for (WebPlatformEntity entity : webPlatformEntityList){
            webPlatformIdList.add(entity.getID());
        }
        return webPlatformIdList;
    }

    @Override
    public List<Integer> queryWebPlatformAreaList(Integer PlatformID) {
        List<WebPlatformAreaEntity> webPlatformAreaEntityList = systemBaseDao.queryWebPlatformAreaList(PlatformID);
        List<Integer> webPlatformAreaIdList = new ArrayList<>();
        for (WebPlatformAreaEntity entity : webPlatformAreaEntityList){
            webPlatformAreaIdList.add(entity.getID());
        }
        return webPlatformAreaIdList;
    }

    @Override
    public List<CfgPatentIndicatorEntity> queryCfgPatentIndicatorList(Integer DateYM, Integer AreaID) {
        List<CfgPatentIndicatorEntity> entityList = systemBaseDao.queryCfgPatentIndicatorList(DateYM,AreaID);
        return entityList;
    }

    @Override
    public Integer queryPlatformIdByAreaId(Integer ID) {
        Integer PlatformID = systemBaseDao.queryPlatformIdByAreaId(ID);
        return PlatformID;
    }

    @Override
    public Integer queryPlatformTypeByPlatformId(Integer ID) {
        Integer PlatformType = systemBaseDao.queryPlatformTypeByPlatformId(ID);
        return PlatformType;
    }

    @Override
    public List<PacPatentinfoEntity> queryPacPatentinfoList(Integer AreaID, Integer PlatformID,String ApplyPerson,Integer ApplyPersonType,String PatAddressLast) {
        List<PacPatentinfoEntity> entityList = systemBaseDao.queryPacPatentinfoList(AreaID,PlatformID,ApplyPerson,ApplyPersonType,PatAddressLast);
        return entityList;
    }

    @Override
    public void updatePacPatentInfoById(Integer ID, Integer PlatformID, Integer ApplyID) {
        systemBaseDao.updatePacPatentInfoById(ID,PlatformID,ApplyID);
    }

    @Override
    public List<PacPatentInfoCountModel> queryPacPatentinfoCount(Integer AreaID, Integer PlatformID, String StartDate, String EndDate) {
        List<PacPatentInfoCountModel> list = systemBaseDao.queryPacPatentinfoCount(AreaID,PlatformID,StartDate,
                EndDate);
        return list;
    }

    @Override
    public List<CfgIpcEntity> queryCfgIpcList(Integer ParentID) {
        List<CfgIpcEntity> list = systemBaseDao.queryCfgIpcList(ParentID);
        return list;
    }

    @Override
    public List<PacPatentInfoCountModel> queryPacPatentinfoForIpcCount(Integer PlatformID, String IPCId) {
        List<PacPatentInfoCountModel> list = systemBaseDao.queryPacPatentinfoForIpcCount(PlatformID,IPCId);
        return list;
    }

    @Override
    public List<PacPatentInfoCountModel> queryPacPatentinfoForInventorCount(Integer PlatformID) {
        List<PacPatentInfoCountModel> list = systemBaseDao.queryPacPatentinfoForInventorCount(PlatformID);
        return list;
    }

    @Override
    public List<PacPatentInfoCountModel> queryPacPatentinfoForAgencyCount(Integer PlatformID, Integer DataType) {
        List<PacPatentInfoCountModel> list = systemBaseDao.queryPacPatentinfoForAgencyCount(PlatformID,DataType);
        return list;
    }

    @Override
    public Integer queryPacPatentinfoForAgencyApplyPersonCount(String AgencyName, Integer PlatformID, Integer DataType) {
        Integer integer = systemBaseDao.queryPacPatentinfoForAgencyApplyPersonCount(AgencyName,PlatformID,DataType);
        return integer;
    }

    @Override
    public void updatePacPatentInfo(Integer PlatformID) {
        systemBaseDao.updatePacPatentInfo(PlatformID);
    }

    @Override
    public void updatePacPatentInfoCity(Integer PlatformID) {
        systemBaseDao.updatePacPatentInfoCity(PlatformID);
    }

    @Override
    public void updatePacPatentInfoOut(Integer PlatformID) {
        systemBaseDao.updatePacPatentInfoOut(PlatformID);
    }

    @Override
    public void updatePacPatentInfoOutCity(Integer PlatformID) {
        systemBaseDao.updatePacPatentInfoOutCity(PlatformID);
    }

    @Override
    public void saveTempRptApplicant(Integer PlatformID, String StartDate, String EndDate) {
        systemBaseDao.saveTempRptApplicant(PlatformID,StartDate,EndDate);
    }

    @Override
    public List<ApplicantInfoModel> queryApplicantInfoList(Integer PlatformID) {
        List<ApplicantInfoModel> list = systemBaseDao.queryApplicantInfoList(PlatformID);
        return list;
    }

    @Override
    public void deleteTempRptApplicant(Integer PlatformID) {
        systemBaseDao.deleteTempRptApplicant(PlatformID);
    }

    @Override
    public void updatePacPatentInfoOutApplyId(Integer PlatformID) {
        systemBaseDao.updatePacPatentInfoOutApplyId(PlatformID);
    }

    @Override
    public void updatePacPatentInfoApplyId(Integer PlatformID) {
        systemBaseDao.updatePacPatentInfoApplyId(PlatformID);
    }

    @Override
    public List<PacPatentInfoCountModel> queryPacPatentinfoForApplicantList(String ApplyPerson, Integer ApplyPersonType, String PatAddressLast) {
        List<PacPatentInfoCountModel> list = systemBaseDao.queryPacPatentinfoForApplicantList(ApplyPerson,
                ApplyPersonType,PatAddressLast);
        return list;
    }
}
